//
//  CellVoiceView.m
//  Budejie
//
//  Created by 远成物流 on 2017/5/16.
//  Copyright © 2017年 陈梦佳. All rights reserved.
//

#import "CellVoiceView.h"
#import "UIImageView+Download.h"

@interface CellVoiceView ()
@property (weak, nonatomic) IBOutlet UIImageView *placeholderView;
@property (weak, nonatomic) IBOutlet UIImageView *voiceImage;
@property (weak, nonatomic) IBOutlet UIButton *playButton;
@property (weak, nonatomic) IBOutlet UILabel *playCount;
@property (weak, nonatomic) IBOutlet UILabel *voiceTime;

@end

@implementation CellVoiceView

-(void)awakeFromNib{
    [super awakeFromNib];
    
    self.autoresizingMask = UIViewAutoresizingNone;
    
    self.voiceImage.userInteractionEnabled = YES;
    
}

- (IBAction)playButtonAction:(id)sender {
}

-(void)setTopic:(EssenceTopic *)topic{
    
    _topic = topic;
    //播放次数
    if (topic.playcount >= 10000) {
        self.playCount.text = [NSString stringWithFormat:@"%.1f万播放",topic.playcount/10000.0];
    }else{
        self.playCount.text = [NSString stringWithFormat:@"%zd播放",topic.playcount];
    }
    
    //时长
    self.voiceTime.text = [NSString stringWithFormat:@"%02zd:%02zd",topic.voicetime/60,topic.voicetime%60];
    
    //图片
    self.placeholderView.hidden = NO;
    [self.voiceImage setOriginalImage:topic.image1 thumbnailImage:topic.image0 placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        if (!image) {
            return ;
        }
        
        self.placeholderView.hidden = YES;
    }];
}

@end
